<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <title>${sysEn}-品牌故事</title>
    <link href="${ctx}/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="${ctx}/css/plugins/dataTables/datatables.min.css" rel="stylesheet">
    <link href="${ctx}/css/animate.css" rel="stylesheet">
    <link href="${ctx}/css/style.css" rel="stylesheet">
    <link href="${ctx}/js/layer/theme/default/layer.css" rel="stylesheet" >
</head>
<body>
    <div id="wrapper">
        <!----左侧导航开始----->
        <#include "/common/menu.ftl">
        <!----左侧导航结束----->

        <!---右侧内容区开始---->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <#include "/common/con_nav.ftl">
            <@con_nav_tag current="品牌故事"></@con_nav_tag>
            <!-- 检索条件开始 -->
            <div class="ibox-content m-b-sm border-bottom">
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-form-label" for="status">状态</label>
                            <select class="form-control m-b" name="status" id="status">
                                <option value="">不限</option>
                                <option value="1">启用</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-2">
                        <div class="form-group">
                            <label class="col-form-label" for="name">标题</label>
                            <input type="text" id="name" name="name" value="" placeholder="" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="text-left">
                    <input type="button" name="" class="btn btn-primary" value="查询" id="btnSubmit"></input>
                </div>
            </div>
            <!-- 检索条件结束 -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox ">
                        <div class="ibox-content">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="example" >
                                </table>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <#include "/common/footer.ftl">
        </div>
        <!---右侧内容区结束---->
     </div>
    <#include "/common/com_table_js.ftl">
    <script>
        $(document).ready(function() {
            var table =  ListPageManager.DataTable.init({
                ajax:{
                    url:"${ctx}/brandstory/pageInfo"
                },
                ajaxParam:function(){
                    var obj = {};
                    if($("#status").val()) {
                        obj["status"] = $("#status").val();
                    }
                    if($("#name").val()) {
                        obj["title"] = $("#name").val();
                    }
                    return obj;
                },
                buttons:[{cmd:'add'},
                		 {cmd:'del',text:'删除',action:function (cmd,e,dt,node,config,tgobj) {
                		    var ids = "";
					        $('.check_select').each(function () {
					            if ($(this).is(':checked')) {
					                ids += $(this).val()+",";
					            } 
					        });
					        if(ids != '' && ids.substring(ids.length-1) == ","){
					            ids = ids.substring(0,ids.length-1)
					        }
					   
					         $.ajax({
                                    url:"${ctx}/brandstory/batchdelete",
                                    type:"post",
                                    data:{ids:ids},
                                    success:function(res){
                                        if(res.success){
                                            ListPageManager.Popup.msg(res.message,{},function(){
                                                 table.redraw();
                                            });
                                        }else{
                                            ListPageManager.Popup.msg(res.message);
                                        }
                                    }
                                })
                    }}],
                addUrl:function(){return "brand_story_edit"},
                updUrl:function(row,data,dataIndex){return "${ctx}/brand_story_edit?id=" + data.id},
                deleteUrl:function(row,data,dataIndex){return "${ctx}/brandstory/delete?id=" + data.id},
                rowCreatedCall:function(row,data,dataIndex){},
                withCheckColumn:{flg:true,key:"id"},
                columns:[
                    {title:"序号",data:"id"},
                    {title:"标题",data:"title"},
                    {title:"状态",render:function (ctx,status,data) {
                        if(data.status == 1){
                            return "启用";
                        }else{
                            return "停用";
                        }
                        }},
                    {title:"创建人",data:"createBy"},
                    {title:"创建时间",render:function (data,type,row) {
                            return ListPageManager.Tools.formatDate(row["createTime"]);
                        }},
              
                    {title:"",toolcolinfo:[{"cmd":"status",gettext:function(data,type,row){
                               if(row.status == 1){
                                   return "停用";
                               }else{
                                   return "启用";
                               }
                            },click:function(cmd,row,data,dataIndex){
                            	var status = 1;
                            	if(data.status == 1){
                            		status = 0;
                            	}
                                 $.ajax({
                                    url:"${ctx}/brandstory/save",
                                    type:"post",
                                    data:{id:data.id,
                                    	  status:status
                                    },
                                    success:function(res){
                                        if(res.success){
                                            ListPageManager.Popup.msg(res.message,{},function(){
                                                 table.redraw();
                                            });
                                        }else{
                                            ListPageManager.Popup.msg(res.message);
                                        }
                                    }
                                })
                            }},
                            {cmd:"upd"},
                            {"cmd":"del"}]}
                ]
            },$("#example"));
            $("#btnSubmit").on("click",function(){
                table.redraw();
            });
        });
    </script>
</body>
</html>
